home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
dax1.exe
/
DAP
/
DAPE
/
DAPSESS.C
< prev
next >
Wrap
Text File
|
1992-07-15
|
4KB
|
112 lines
// ╔════════════════════════════════════════════════════════════════════╗
// ║ ║
// ║ module: dapsess.c ║
// ║ abstract: This module contains session support for the engine. ║
// ║ ║
// ║ environment: NetWare 3.x v3.11 ║
// ║ Network C for NLMs SDK ║
// ║ CLib v3.11 ║
// ║ ║
// ║ This software is provided as is and carries no warranty ║
// ║ whatsoever. Novell disclaims and excludes any and all implied ║
// ║ warranties of merchantability, title and fitness for a particular ║
// ║ purpose. Novell does not warrant that the software will satisfy ║
// ║ your requirements or that the software is without defect or error ║
// ║ or that operation of the software will be uninterrupted. You are ║
// ║ using the software at your risk. The software is not a product ║
// ║ of Novell, Inc. or any of subsidiaries. ║
// ║ ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ maintenance history: ║
// ║ level date pi description ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ 001 03/03/92 kl initial release. ║
// ╚════════════════════════════════════════════════════════════════════╝
#include <stdio.h>
#include <string.h>
#include "dap/dapsys.h"
//
// maximumSessions holds the current size of the 'dapsessions' array.
// If you make this a pointer, you can dynamically grow and shrink the
// size of the array.
//
STATIC UINT32 maximumSessions = DEFMAXSESSIONS;
STATIC DAPDATA dapsessions[DEFMAXSESSIONS];
UINT32 DAPGetMaximumNumberOfSessions() { return maximumSessions; }
//
// Return a pointer to the array.
//
DAPDATA *DAPGetClientArray() { return dapsessions; }
//
// The following routine is called during startup, it could be
// used to allocate memory for a 'dynamic' session array
//
T_RC DAPInitializeSessLogic() { return DAP_SUCCESS; }
//
// Called during shutdown procedure.
//
void DAPDeInitializeSessLogic() {}
UINT32 DAPSeeIfActiveCPid(UINT32 CPid)
{
int i;
for(i=0; i < maximumSessions; ++i){
if( DAPSlotInUse( &dapsessions[i] ) && dapsessions[i].CPid == CPid) {
return i;
}
}
return -1;
}
//
// Allocate a slot in the session array. This API is called from
// DAPEnqueueServiceRequest() when it detects a new session is needed.
// This occurs when an invalid session id is passed in, normally 0,
// when the client is performing DAPAllocateSession().
//
UINT32 DAPAllocateSlot()
{
int i;
for(i=0; i < maximumSessions; ++i){
if( !DAPSlotInUse( &dapsessions[i] ) ) {
DAPStateON(&dapsessions[i],DAP_SLOTINUSE);
DAPIncActiveSessions();
return i;
}
}
return -1;
}
void DAPDeAllocateSlot(DAPDATA *DAPid)
{
if( DAPSlotInUse(DAPid) ){
DAPStateOFF(DAPid,DAP_SLOTINUSE);
//!!
//!!
//!!
#if 0
memset(DAPid,NULL,sizeof *DAPid);
#else
//
// Got to reset this, or we'll have a synchronization problem.
//
DAPid->DAPState = DAPid->DAPFlags = 0;
#endif
DAPDecActiveSessions();
}
}